package com.example.mys_app;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class recyclerViewActivity extends AppCompatActivity {

    RecyclerView recyclerView;
    List list;
    Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyleview);

        recyclerView=findViewById(R.id.recyclerview);

        list=new ArrayList();
        for(int i=0;i<10;i++){
            list.add("这是第"+i+"行数据");
        }

        context=this;
        Myadapter adapter=new Myadapter(context,list);

        recyclerView.setAdapter(adapter);

        LinearLayoutManager manager=new LinearLayoutManager(context);
        manager.setOrientation(recyclerView.VERTICAL);
        recyclerView.setLayoutManager(manager);

    }
}